/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.tordroid.ui;

import android.app.Fragment;
import android.os.Bundle;
import android.view.*;
import android.widget.ImageView;
import android.widget.TextView;
import de.tordroid.R;
import de.tordroid.core.Engine;

/**
 *
 * @author Christian Simon
 */
public class OverviewFragment extends Fragment {

    private static OverviewFragment fragment;
    private TextView text_titel;
    private ImageView img_availability;
    private ImageView img_race;
    private ImageView img_faction;
    private ImageView img_class;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public static OverviewFragment newInstance() {
        fragment = new OverviewFragment();
        return fragment;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        
        initUI();
        updateContent();
    }

    private void initUI() {
        // Preparing UI Elements
        text_titel = (TextView) getView().findViewById(R.id.overview_fragment_titel);
        img_availability = (ImageView) getView().findViewById(R.id.overview_fragment_availability);
        img_race = (ImageView) getView().findViewById(R.id.overview_fragment_race);
        img_faction = (ImageView) getView().findViewById(R.id.overview_fragment_faction);
        img_class = (ImageView) getView().findViewById(R.id.overview_fragment_class);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.overview_fragment, container, false);

        return view;
    }

    public void updateContent() {
        // Manipulating UI Elements
        text_titel.setText(Engine.getCharacterFullname());
        img_availability.setImageResource(Engine.getAvailabilityIcon(Engine.getCurrentCharacter()));

        img_race.setImageResource(Engine.getRaceIcon());
        img_faction.setImageResource(Engine.getFactionIcon());
        img_class.setImageResource(Engine.getClassIcon());
    }
}
